package com.xxxy.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxxy.dao.AdminDao;
import com.xxxy.exception.MyException;
import com.xxxy.model.Admin;
import com.xxxy.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @author sjh
 * @date 2022/1/23 12:13
 */
@Service
public class AdminServiceImpl extends ServiceImpl<AdminDao, Admin> implements AdminService{

    @Autowired
    AdminDao adminDao;

    @Override
    public Admin loginByAdmin(String account, String pwd) {
        Admin admin =  adminDao.getAdminByAccount(account);
        if(admin == null){
            throw new MyException("用户名密码错误");
        }
        else if(!admin.getPwd().equals(pwd)){
            throw new MyException("用户名密码错误");
        }
        else{
            return admin;
        }
    }
}
